#include "Tools.h"

Tools::Tools() {

}

Tools::~Tools() {

}

string Tools::Converter(float value) {
	stringstream ss;
	ss << value;
	return ss.str();
}

float Tools::Converter(string line) {
	float temp = ::atof(line.c_str());
	return temp;
}

int Tools::ConverterI(string line) {
	return (int)Converter(line);
}

int Tools::GetSec(clock_t time) {
	return (int) GetSecDecimal(time);
}

float Tools::GetMilliSec(clock_t time) {
	clock_t t0;
	t0 = clock();
	float diff = ((float)t0 - (float)time);
	return diff;
}

float Tools::GetSecDecimal(clock_t time) {
	clock_t t0;
	t0 = clock();
	float diff = ((float)t0 - (float)time);
	return diff / CLOCKS_PER_SEC;
}

clock_t Tools::GetTime() {
	clock_t t0;
	t0 = clock();
	return t0;
}

string Tools::GetInput() {
	char str[256];
	string input = "";
	while (true){
		try {
			cin.getline(str,256);
			break;
			} catch (...) {
				cout << "Exception. Redo.";
		}
	}

	int i = 0;
	while (str[i]) {
		input = input + str[i];
		i++;
	}

	return input;
}